| Conditions | 1 |
| Paths | 1 |
| Total Lines | 64 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 3 | ||
| Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | /** global: Clipboard */ |
||
| 2 | $(document).ready(function () { |
||
| 3 | var clipboard = new Clipboard('.copy-link'); |
||
|
|
|||
| 4 | clipboard.on('success', function (e) { |
||
| 5 | var $input = $(e.trigger); |
||
| 6 | $input.tooltip('hide') |
||
| 7 | .attr('data-original-title', t('core', 'Copied!')) |
||
| 8 | .tooltip('fixTitle') |
||
| 9 | .tooltip({placement: 'bottom', trigger: 'manual'}) |
||
| 10 | .tooltip('show'); |
||
| 11 | _.delay(function () { |
||
| 12 | $input.tooltip('hide'); |
||
| 13 | if (OC.Share.Social.Collection.size() === 0) { |
||
| 14 | $input.attr('data-original-title', t('core', 'Copy')) |
||
| 15 | .tooltip('fixTitle'); |
||
| 16 | } else { |
||
| 17 | $input.tooltip('destroy'); |
||
| 18 | } |
||
| 19 | }, 3000); |
||
| 20 | }); |
||
| 21 | clipboard.on('error', function (e) { |
||
| 22 | var $input = $(e.trigger); |
||
| 23 | var actionMsg = ''; |
||
| 24 | if (/iPhone|iPad/i.test(navigator.userAgent)) { |
||
| 25 | actionMsg = t('core', 'Not supported!'); |
||
| 26 | } else if (/Mac/i.test(navigator.userAgent)) { |
||
| 27 | actionMsg = t('core', 'Press ⌘-C to copy.'); |
||
| 28 | } else { |
||
| 29 | actionMsg = t('core', 'Press Ctrl-C to copy.'); |
||
| 30 | } |
||
| 31 | |||
| 32 | $input.tooltip('hide') |
||
| 33 | .attr('data-original-title', actionMsg) |
||
| 34 | .tooltip('fixTitle') |
||
| 35 | .tooltip({placement: 'bottom', trigger: 'manual'}) |
||
| 36 | .tooltip('show'); |
||
| 37 | _.delay(function () { |
||
| 38 | $input.tooltip('hide'); |
||
| 39 | if (OC.Share.Social.Collection.size() == 0) { |
||
| 40 | $input.attr('data-original-title', t('core', 'Copy')) |
||
| 41 | .tooltip('fixTitle'); |
||
| 42 | } else { |
||
| 43 | $input.tooltip("destroy"); |
||
| 44 | } |
||
| 45 | }, 3000); |
||
| 46 | }); |
||
| 47 | |||
| 48 | $('.alt-tooltip').tooltip(); |
||
| 49 | |||
| 50 | $('.delete-poll').click(function () { |
||
| 51 | deletePoll(this); |
||
| 52 | }); |
||
| 53 | |||
| 54 | $('.table-body .avatardiv').each(function (i, obj) { |
||
| 55 | $(obj).avatar(obj.title, 32); |
||
| 56 | }); |
||
| 57 | |||
| 58 | $('.popupmenu').each(function () { |
||
| 59 | OC.registerMenu($('#expand_' + $(this).attr('value')), $('#expanddiv_' + $(this).attr('value')) ); |
||
| 60 | }); |
||
| 61 | |||
| 62 | $('.copy_link').click(function () { |
||
| 63 | window.prompt(t('polls','Copy to clipboard: Ctrl+C, Enter'), $(this).data('url')); |
||
| 64 | }); |
||
| 65 | }); |
||
| 66 |